using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

namespace DD.Logging
{
    public static class Log
    {
        public static void WriteLine(string LogLine)
        {
            string filename = "DD_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            string fullpath = HttpContext.Current.Server.MapPath("~/Logs/" + filename);

            FileStream file;
            if (File.Exists(fullpath))
            {
                file = new FileStream(fullpath, FileMode.Append, FileAccess.Write);
            }
            else
            {
                file = new FileStream(fullpath, FileMode.OpenOrCreate, FileAccess.Write);
            }
            
             
            string Line1 = DateTime.Now.ToShortDateString() + "  " + DateTime.Now.ToLongTimeString();

            StreamWriter sw = new StreamWriter(file);
            sw.WriteLine(Line1);
            sw.WriteLine(LogLine);
            sw.WriteLine(sw.NewLine);
            sw.Close();

            file.Close();
            
        }

    }
}
